package org.junv;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/AddUser")
public class AddUser extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   //添加用户名
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         response.setContentType("text/html;charset=utf-8");
         PrintWriter out =  response.getWriter();
         String sql = null;
        
         
         String user =  request.getParameter("user");
         String password = request.getParameter("password");
         if(user==""||password==""){
        	 out.println("用户名和密码不能为空请重新输入！");
        	 return;
         }
         sql = "insert into userInfo (username,password) values('"+user+"','"+password+"')";
         DBBean myBean = new DBBean();
         myBean.init();
         if(myBean.executeUpdate(sql)){
        	 out.println("添加用户名"+user+"成功！");
        	 System.out.println(".........添加成功");
         }

	}



}
